﻿/*==============================================================
 * LinkGroupExtensions.cs
 * Copyright (C) 2014 贵州惠众互联 Inc. All rights reserved.
 *==============================================================
 * Author:   罗应红
 * Date:     2014/03/04 16:58:16.
 * Version:  1.0
 * QQ:		 88962800
*==============================================================*/

using System;
using System.Collections.Generic;
using System.Linq;
using QDT.Core.Domain;
using QDT.Web.Admin.Models;

namespace QDT.Web.Admin.Helper {
    public static class LinkGroupExtensions {
        public static IList<LinkGroupModel> ToModelList(this IList<LinkGroup> linkGroups) {
            return linkGroups.Select(ToModel).ToList();
        }

        public static LinkGroupModel ToModel(this LinkGroup linkGroup) {
            return new LinkGroupModel {
                IsEffect = linkGroup.IsEffect,
                Id = linkGroup.ID,
                Sort = linkGroup.Sort,
                Name =  linkGroup.Name
            };
        }
        public static LinkGroup ToEntity(this LinkGroupModel model) {
            return new LinkGroup {
                IsEffect = model.IsEffect,
                Sort = model.Sort,
                ID = model.Id,
                Name =  model.Name
            };
        }
    }
}